From 82830c77bd4daa596acef04c12952b25510977d1 Mon Sep 17 00:00:00 2001 From: Ewan Higgs Date: Wed, 29 Mar 2017 21:51:50 +0200 Subject: [PATCH] Revert "Use time crate directly to get the year" This reverts commit 47221e98189daa34e47934d44223db12db84c7b9. --- Cargo.lock | 12 +++++++++++- Cargo.toml | 2 +- src/cargo/lib.rs | 2 +- src/cargo/ops/cargo_new.rs | 3 ++- tests/new.rs | 8 +++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 140f2aa2c..bfce30111 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,7 @@ dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cargotest 0.1.0", + "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", "crates-io 0.7.0", "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -36,7 +37,6 @@ dependencies = [ "tar 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -105,6 +105,15 @@ name = "cfg-if" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "chrono" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cmake" version = "0.1.20" @@ -825,6 +834,7 @@ dependencies = [ "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" +"checksum chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00" "checksum cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a6805df695087e7c1bcd9a82e03ad6fb864c8e67ac41b1348229ce5b7f0407" "checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" "checksum curl 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c90e1240ef340dd4027ade439e5c7c2064dd9dc652682117bd50d1486a3add7b" diff --git a/Cargo.toml b/Cargo.toml index 91fcbd0dc..5e83d2e2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ name = "cargo" path = "src/cargo/lib.rs" [dependencies] +chrono = "0.2.25" crates-io = { path = "src/crates-io", version = "0.7" } crossbeam = "0.2" curl = "0.4.6" @@ -43,7 +44,6 @@ shell-escape = "0.1" tar = { version = "0.4", default-features = false } tempdir = "0.3" term = "0.4.4" -time = "0.1.36" toml = "0.3" url = "1.1" diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 736a9c04d..3c27a332e 100755 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -5,6 +5,7 @@ #[macro_use] extern crate log; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; +extern crate chrono; extern crate crates_io as registry; extern crate crossbeam; extern crate curl; @@ -26,7 +27,6 @@ extern crate shell_escape; extern crate tar; extern crate tempdir; extern crate term; -extern crate time; extern crate toml; extern crate url; diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 18a62c7fc..536b2bc50 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -8,9 +8,9 @@ use git2::Config as GitConfig; use term::color::BLACK; +use chrono::{Datelike,Local}; use handlebars::{Handlebars, no_escape}; use tempdir::TempDir; -use time; use toml; use core::Workspace; @@ -521,6 +521,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> { let mut data = BTreeMap::new(); data.insert("name".to_owned(), name.to_owned()); data.insert("author".to_owned(), author); + data.insert("year".to_owned(), Local::now().year().to_string()); let template_set = try!(get_input_template(config, opts)); for template in template_set.template_files.iter() { diff --git a/tests/new.rs b/tests/new.rs index 9f9d3ba29..b212ba843 100644 --- a/tests/new.rs +++ b/tests/new.rs @@ -1,8 +1,8 @@ extern crate cargo; extern crate cargotest; +extern crate chrono; extern crate hamcrest; extern crate tempdir; -extern crate time; use std::fs::{self, File}; use std::io::prelude::*; @@ -11,6 +11,7 @@ use std::env; use cargo::util::ProcessBuilder; use cargotest::process; use cargotest::support::{execs, git, paths}; +use chrono::{Datelike,Local}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; use tempdir::TempDir; @@ -97,6 +98,11 @@ fn main () { assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); assert_that(&paths::root().join("foo/src/main.rs"), existing_file()); + let license = paths::root().join("foo/LICENSE"); + let mut contents = String::new(); + File::open(&license).unwrap().read_to_string(&mut contents).unwrap(); + assert!(contents.contains(&format!("(c) {} {}", Local::now().year(), "foo"))); + assert_that(cargo_process("build").cwd(&paths::root().join("foo")), execs().with_status(0)); assert_that(&paths::root().join(&format!("foo/target/debug/foo{}", -- 2.30.2